#
#
# @Author Man
# @Date 2020-12-18-16:48
import time

from selenium import webdriver

#browser =
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
#chrome_options=chrome_options,
driver = webdriver.Chrome( executable_path="D:\program\chromedriver.exe")
driver.maximize_window()
driver.get('https://www.zhipin.com/chengdu/')

java = driver.find_element_by_xpath('//*[@id="main"]/div/div[1]/div/dl[1]/dd/a[1]')
java.click()

num = 1
page = 1
while 1:
    title = driver.find_element_by_xpath(
        '//*[@id="main"]/div/div[3]/ul/li[' + str(num) + ']/div/div[1]/div[1]/div/div[1]/span[1]/a')
    print("工作岗位:" + title.text + "\n")
    area = driver.find_element_by_xpath(
        '//*[@id="main"]/div/div[3]/ul/li[' + str(num) + ']/div/div[1]/div[1]/div/div[1]/span[2]/span')
    print("工作地点:" + area.text + "\n")
    company_name = driver.find_element_by_xpath(
        '//*[@id="main"]/div/div[3]/ul/li[' + str(num) + ']/div/div[1]/div[2]/div/h3/a')
    print("公司:" + company_name.text + "\n")
    money = driver.find_element_by_xpath(
        '//*[@id="main"]/div/div[3]/ul/li[' + str(num) + ']/div/div[1]/div[1]/div/div[2]/span')
    print("薪资:" + money.text + "\n")
    working_years_and_education = driver.find_element_by_xpath(
        '//*[@id="main"]/div/div[3]/ul/li[' + str(num) + ']/div/div[1]/div[1]/div/div[2]/p')
    print("工作年限要求|学历:" + working_years_and_education.text + "\n")
    company_details = driver.find_element_by_xpath(
        '//*[@id="main"]/div/div[3]/ul/li[' + str(num) + ']/div/div[1]/div[2]/div/p')
    print("公司情况:" + company_details.text + "\n")
    welfare = driver.find_element_by_xpath('//*[@id="main"]/div/div[3]/ul/li[' + str(num) + ']/div/div[2]/div[2]')
    print("福利:" + welfare.text + "\n")
    print("-------------------------------------------------------------------------")
    num += 1
    if num == 29:
        if page == 1:
            driver.find_element_by_xpath('//*[@id="main"]/div/div[3]/div[3]/a[5]').click()
        if page == 2:
            driver.find_element_by_xpath('//*[@id="main"]/div/div[2]/div[2]/a[6]').click()
        if page == 3:
            driver.find_element_by_xpath('//*[@id="main"]/div/div[2]/div[2]/a[7]').click()
        if page == 4:
            driver.find_element_by_xpath('//*[@id="main"]/div/div[2]/div[2]/a[8]').click()
        if page == 5:
            driver.find_element_by_xpath('').click()
        page += 1
        num = 1